<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
 	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.4.4.min.js"></script>
 	<script type="text/javascript" src="${pageContext.request.contextPath}/My97DatePicker/WdatePicker.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/homepages/js/functions.js"></script>
	<script type="text/javascript">
		var formType = "${formType}";
		$(function(){
			//填充相应的录单界面
			loadPages();
		});
		function loadPages(){
			$('#pages').load('${pageContext.request.contextPath}/sys/inputForms',
				{'formType':formType});
		}
		var pan=0;
		function addTopic(){
			$.ajax({
				type:'post',
				url:'${pageContext.request.contextPath}/topic/saveTopic',
				data:$('#topicForm').serialize(),
				success:function(data){
					$('#dsId').val(data);
					if(pan == 0){
						findOtherButn();
						pan =1;
					}
					
				}
			})
			
		}
		
		function findOtherButn(){
			var formId= $('#formId').val();
			$.ajax({
				 type:'post',
				 url:'${pageContext.request.contextPath}/topic/specialButn',
				 data:{'formType':formId,'name':'applyTopics'},
				 success:function(da){
				 	//拼接到保存按钮后面
				 	var butns= $('#butn');
				 	for(var i=0;i<da.length;i++){
				 		butns.append("<input type='button' value="+da[i].butnName+" onclick="+"'"+da[i].scriptFunc+"'"+"/>");
				 	}
				 }
			})
		}
		function applyTopic(){
			var dsId = $('#dsId').val();
			$.ajax({
				type:'post',
				url:'${pageContext.request.contextPath}/topic/approvesTopic',
				data:{'dsId':dsId},
				success:function(data){
					alert("OK"+data.length);
					var str="<div style='border: 1px solid; width: 800px;'>";
					$('#applyTopic').show();
					$('#applyTopic').dialog({
						width:'900',
						collapsible: true,
						minimizable: true,
						maximizable: true
					});
					//把列加载到div
					str+="<table><tr><td>审批名称</td><td><input type='text' /></td><td>上级审批</td>"+
							"<td><select><option>是</option>	<option>否</option></select>	</td><td>允许审批</td><td><select>"+
							"<option>是</option>	<option>否</option></select></td></tr><tr><td>审批意见</td><td colspan='5'>"+
							"<textarea rows='2' cols='70'></textarea><input type='button' value='...'/></td></tr>"+
							"<tr><td>状态</td><td><input type='text' value='已通过'/></td><td>审批日期</td><td><input type='text'/></td>"+
							"<td>审批人</td><td><input type='text'/></td></tr></table>"
					str+="</div>";
					var str1="<table><tr><td><input type='button' value='保存' onclick='saveApply()'/></td></tr></table>";
					for(var i=0;i<data.length;i++){
						$('#applyTopic').append(str);
					}
					$('#applyTopic').append(str1);
				}
				
			})
		}
		function saveApply(){
			alert("保存");
			//$.ajax({
				//type:'post',
				//url:'',
				//data:'',
				//success:function(){
					//alert("OK");
				//}
			//})
		}
	</script>
</head>
<body>
	<!-- 显示标题 -->
	<!--	<div style="color: #0000; font-size: 13pt;font-family: '黑体';">${uiObject.dsName }</div>-->
	<form action="" method="post" id="topicForm">
		<div style="text-align: center; " id="pages">
			<!-- 加载入单界面 -->
		</div>
	</form>
	<div id="applyTopic" style="display: none;"></div>
	<input id="formId" type="hidden" value="${formType}"/>
	<input id="dsId" type="hidden" />
	
</body>
</html>